#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    bool f=0;
    int mn=99;
    int x,in;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')f=1;
        if(i<n-1)
        {
            x=(s[i]-'0')*10+s[i+1]-'0';
            int a=mn/10,b=mn%10;
            // mn=min(mn,x);
            int q=x,p=mn;
            if(a!=1)q=x+a;
            if(b!=1)q+=b;
            if(s[i]!='1')p=mn+s[i]-'0';
            if(s[i+1]!='1')p+=s[i+1]-'0';
            if(q<p)
            {
                in=i;
                mn=x;
            }
        }
    }
    if(n<=2)
    {
        if(s[0]=='0')cout<<s[1]<<endl;
        else cout<<s[0]<<s[1]<<endl;
    }
    else
    {
        // if(f)cout<<0<<endl;
        if(mn==0||(n>=4&&f)||(n==3&&(s[0]=='0'||s[2]=='0')))cout<<0<<endl;
        else
        {
            for(int i=0;i<n;i++)
            {
                if(s[i]=='1'||i==in||i==in+1)continue;
                if(s[i]=='0')
                {
                    mn=0;
                    break;
                }
                if(mn==1)mn=s[i]-'0';
                else mn+=s[i]-'0';
            }
            cout<<mn<<endl;
        }
    }
    
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}